<script type="text/javascript" src="components/nguoiban/js.js"></script>
<?php

	if (isset($_GET['ajax']))
	{
		include_once ('../../includes/configuration.php');
		include_once ('../../includes/database.php');
		include_once ('../../components/sukien/class_sukien.php');
		
		$obj_config = new Config();

	}
	else
	{
		include_once ('components/sukien/class_sukien.php');
	}
	
?>

<?php 
	include_once('class_pages.php');
?>

<?php 
	$sk = new class_sukien();
	$count = $sk->CountListSuKienByNguoiBan($_GET['MaNguoiBan']);
	
	$pager = new Pager();
	$limit = 3 ;
		
	$start = $pager->findStart($limit);
	$pages = $pager->findPages($count,$limit);

	$ls = '' ;
	$listpaging = '' ;
	if($count > $limit)
	{
		$listpaging = $pager->pageList($_GET['page'], $pages,$ls, 1);
	}

	$tb = $sk->ListSuKienByNguoiBan($_GET['MaNguoiBan'],$start,$limit);
	$str = '';
	echo '<h1>Sự kiện</h1>';
	if (count($tb) == 0)
	{
		echo '<br/><div align="center"><b>Không có sự kiện.</b></div>';
	}
	foreach ($tb as $row)
	{
		$str .= '<table align="center" width="710" border="0">
  <tr>
    <td width="130" rowspan="3"><img src="../images/sukien/event.png" width="120px" height="120px" /></td>
    <td align="left" colspan="2" style="font-weight:bold; font-size:16px">';
	
	if ($row['TenSuKien'] == NULL)
	{
		$row['TenSuKien'] = 'sản phẩm bị xóa';
	}
	
	$str .= '<a href="#">'.$row['TenSuKien'].'</a></td>
  </tr>
  <tr>
    <td width="290">Ngày bắt đầu: ';
	
	$ThoiGian = $row['NgayBatDau'];
	$nam = substr($ThoiGian,0,4);
	$thang = substr($ThoiGian,5,2);
	$ngay = substr($ThoiGian,8,2);
	$gio = substr($ThoiGian,11,2);
	$phut = substr($ThoiGian,14,2);
	$giay = substr($ThoiGian,17,2);
	$ThoiGian = $ngay.'/'.$thang.'/'.$nam;
	
	$str .= $ThoiGian.'</td>
	<td>Ngày kết thúc: ';
	
	$ThoiGian = $row['NgayKetThuc'];
	$nam = substr($ThoiGian,0,4);
	$thang = substr($ThoiGian,5,2);
	$ngay = substr($ThoiGian,8,2);
	$gio = substr($ThoiGian,11,2);
	$phut = substr($ThoiGian,14,2);
	$giay = substr($ThoiGian,17,2);
	$ThoiGian = $ngay.'/'.$thang.'/'.$nam;
	
	$str .= $ThoiGian.'</td>
  </tr>';
  
	
 	  $str .= '<tr>
    			<td colspan="2">Nội dung: '.$row['NoiDungSuKien'].'</td>
  			</tr>';
  
  $str .= '<tr>
    <td colspan="3">
    <hr align="center" style="border:thin dotted" color="#00CC00"  />
    </td>
 </tr>
</table>';
		
	}
	$str .= '<div align="center">'.$listpaging.'</div>';
	echo $str;

?>